<template>
  <div ref="fullScreen">
    <status v-if="" :msgDetail="msgDetail" :btnTxt="btnTxt" :msgTitle="msgTitle"
            :type="type" :title="title" @onBtnClick="resetInfo" @onBack="resetInfo1"></status>
  </div>
</template>

<script>
  import {GET_REGISTER_STATE} from '../../assets/js/api'
  import Status from "../../components/module/Status.vue";

  export default {
    components: {Status},
    name: 'pending',
    data() {
      return {
        msgDetail: '审核结果将于24小时内发送至您的手机，请耐心等待。',
        btnTxt: '修改资料',
        msgTitle: '等待审核中',
        type: 'pending',
        title: '等待审核'
      }
    },
    async created() {
      const isFirst = this.$route.query.isFirst;
      if (this.$store.state.registerRecord) {
        let {type, token, member_id} = this.$store.state.registerRecord;
        if (type === 3) {
          let json = await this.$http.post(GET_REGISTER_STATE, {member_id, token});
          console.log(json)
          if(json.result===1){
            if(json.data.status===2&&json.data.qualified_status===2){
              this.$router.isBack = true;
              this.$router.push('/login');
            }
            if(json.data.status===1&&json.data.qualified_status===1) {
              const {off} =  this.$route.params;
              if (off) {
                this.title = '提交成功';
                this.type = 'success';
                this.btnTxt = ''
                this.msgTitle = '您的资料已提交审核！';
              }
            }
            if(json.data.status===3||json.data.qualified_status===3){
              this.title = '打回原因';
              this.type = 'faild';
              this.msgTitle = '审核未通过';
              let msgDetail = json.data.msgDetail!==""?'个人信息:'+json.data.msgDetail : '';
              let qualified_reason =  json.data.qualified_reason!==""?'认证信息:'+ json.data.qualified_reason:'';
              this.msgDetail =  msgDetail +" "+  qualified_reason;
              this.btnText = '重新提交';
            }
          }
//          switch (json.data.status) {
//            case 1:
//              if (isFirst) {
//                this.title = '提交成功';
//                this.type = 'success';
//                this.btnTxt = ''
//                this.msgTitle = '您的资料已提交审核！';
//              }
//              break;
//            case 2:
//              this.$router.isBack = true;
//              this.$router.push('/login');
//              break;
//            case 3:
//              this.title = '打回原因';
//              this.type = 'faild';
//              this.msgTitle = '审核未通过';
//              this.msgDetail = '打回原因:' + json.data.msgDetail || '暂无';
//              this.btnText = '重新提交';
//              break;
//          }

        }
      }
    },
    methods: {
      resetInfo() {
//        const isFirst = this.$route.query.isFirst;
//        this.$router.isBack = true;
//        if (isFirst) {
//          this.$router.go(-1);
//          this.$router.push({path: '/login'});
//        } else {
          this.$router.push('/register/addProfile')
//        }
      },
      resetInfo1(){
        const isFirst = this.$route.query.isFirst;
        this.$router.isBack = true;
        if (isFirst) {
//          this.$router.go(-1);
          this.$router.push({path: '/login'});
        }
        this.$router.push({path: '/login'});
      }
    }
  }
</script>
